<template>
	<view class="add-list ">
		<view class="add-wrapper df-cen-rl" v-for="(item, idx) in addList" :key="idx" >
			<view class="flex1" @click="selectAdd(item, idx)">
				<view class=" add-item">
					<view class="add-name">{{ item.name }}</view>
					<view class="add-tel">{{ item.mobile }}</view>
					<view class="default bg-gradual-orange round" v-if="item.is_default == 1">默认</view>
				</view>
				<view class="add">{{ item.full_address }}</view>
			</view>
			<view class="edit" @click="goAddDetail(item, idx)">编辑</view>
		</view>
	</view>
</template>
<script>
import { addMemberaddress, editMemberaddress, delMemberaddress } from '@/common/js/request/modules/public.js';
export default {
	data() {
		return {
			backUrl: '',
			pagesLen:null
		};
	},
	props: {
		addList: {
			type: Array,
			default() {
				return [];
			}
		}
		// type: {
		//     type: String,
		//     default() {
		//         return []
		//     }
		// }
	},
	mounted(){
		this.pagesLen = getCurrentPages().length;
	},
	methods: {
		goAddDetail(item, idx) {
			// console.log('log', item, idx);
			this.$Router.push({
				name: 'changeAddress',
				query: {
					id: item.id
				}
			});
			// console.log('log1111',this.$Router.queryObj().backUrl);
			// return false
			// setTimeout(() => {
			// 	uni.$emit('addressDetail', this.addList[idx]);
			// }, 300);
			// let ceshi = this.$Router.queryObj().backUrl;
			// console.log('log', this.$Router.queryObj().backUrl, JSON.parse(decodeURIComponent(ceshi)), '12321');
			// return false;
			// this.$Router.push({
			// 	name: 'changeAddress',
			// 	query: {
			// 		// backUrl: this.$Router.queryObj().backUrl
			// 	}
			// });
		},
		selectAdd(item, idx){
			let id = this.$Router.queryObj().buy
			if(id){
				// console.log("item",item)
				this.$Apis.setdefault({id:item.id}).then(res=>{
					console.log(res)
				// 判断页面栈是否只有一个
				if (this.pagesLen == 1) {
					uni.reLaunch({
						url: '/pages/index/index'
					});
				} else {
					uni.navigateBack({
						delta: 1
					});
				}
				}).catch(err=>{
					console.log(res)
				})
			}
		}
	}
};
</script>
<style lang="scss">
.addMore {
	padding-right: 10px;
}

.add-wrapper {
	padding: 10px 0;
	.edit {
		padding: 15px 0 15px 15px;
		border-left: 1px solid lightgray;
		color: #999999;
	}
	.add {
		font-size: 16px;
	}
	.add-item {
		justify-content: flex-start;
		display: flex;
		align-items: baseline;
		margin-bottom: 5px;
		.default {
			padding: 2px 10px;
			font-size: 10px;
		}
		.add-name {
			margin-right: 10px;
			font-size: 16px;
		}
		.add-tel {
			font-size: 12px;
			margin-right: 20px;
			color: lightgrey;
		}
	}
}
.boder-padding {
	background-color: #fff;
	padding: 15px 0;
	border-bottom: 1px solid #f4f4f4;
}
</style>
